<extend name="Layout/layout" />
<block name="include">
	
</block>
<block name="main">
	<div class="col-md-4 col-md-offset-4 form-register">
		<form role="form" id="register-form" action="<{:U('doregister')}>" method="post">
		  	<div class="form-group">
		    	<label for="exampleInputUsername">用户名</label>
		    	<input type="text" class="form-control" name="username" id="exampleInputUsername" placeholder="用户名"
					   data-container="body" data-toggle="popover" data-placement="right" data-content="用户名">
		  	</div>
		  	<div class="form-group">
		    	<label for="exampleInputEmail">Email</label>
		    	<input type="email" class="form-control" name="email" id="exampleInputEmail" placeholder="Email"
					   data-container="body" data-toggle="popover" data-placement="right" data-content="email">
		  	</div>
		  	<div class="form-group">
		    	<label for="exampleInputPassword1">密码</label>
		    	<input type="password" class="form-control" name="password" id="exampleInputPassword1" placeholder="密码"
					   data-container="body" data-toggle="popover" data-placement="right" data-content="密码格式">
		  	</div>
		  	<div class="form-group">
		    	<label for="exampleInputPassword2">确认密码</label>
		    	<input type="password" class="form-control" name="repassword" id="exampleInputPassword2" placeholder="确认密码"
					   data-container="body" data-toggle="popover" data-placement="right" data-content="两次输入的密码不一致">
		  	</div>

		  	<button type="submit" class="btn btn-info">注&nbsp;&nbsp;册</button>
		</form>
		<script>
			$(function(){
				var regForm = $('#register-form');
				var password2 = $('#exampleInputPassword2');
				var username = $('#register-form #exampleInputUsername');
				var password = $('#register-form #exampleInputPassword1');
				var email = $('#register-form #exampleInputEmail');
				password2.change(function(){
					if(password.val()!==password2.val()){
						password2.popover('show');
					}
				});

				togglePopover(username,/^[\u4E00-\u9FA5a-zA-Z0-9_]{3,20}$/,'用户名格式不正确');
				togglePopover(email,/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,'邮箱格式不正确');
				togglePopover(password,/^[a-zA-Z]\w{5,17}$/,'密码格式不正确');
				regForm.submit(function(){

					var resUserName = checkRule(username,/^[\u4E00-\u9FA5a-zA-Z0-9_]{3,20}$/);
					if(!resUserName){
//						popMSG('用户名格式','用户名含有特殊字符');
						return false;
					}
					var resPassWord = checkRule(password,/^[a-zA-Z]\w{5,17}$/);
					if(!resPassWord){
						popMSG('密码格式','以字母开头，只能包含字符、数字和下划线的6-18个字符');
						return false;
					}
					var resEmail = checkRule(email,/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/);
					if(!resEmail){
						popMSG('Email格式','Email格式不正确');
						return false;
					}
				});
			})
		</script>
	</div> 
	<!--<div class="col-md-4">-->
		<!--<include file="./Application/Home/View/Public/hotarticle.html" />-->
	<!--</div>-->
</block>